<%@ page language="java" contentType="text/html; charset=utf-8"pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="/xboard/css/common.css" rel="stylesheet" type="text/css">
<title>Xboard</title>
</head>
<script type="text/javascript">
	function fn_write(){
		var obj=document.frm;
		obj.submit();
	}
	
	function fn_search(){
		var obj = document.searchFrm;
		if(obj.searchText.value == ''){
			alert("검색 내용이 없을시 전체 게시물을 가져옵니다.");
			document.location.href="./list.action";
		}else{
			obj.submit();
		}
	}
</script>
<body>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr>
    	<td style="padding:50px 0 10px 0; font-size:13px; font-weight:bold;" align="center">Xboard</td>
    </tr>
	<tr>
    	<td align="center">
    		<table width="780" border="0" cellpadding="0" cellspacing="0" align="center" style="margin:5px 0 5px 0;">
				<tr>
					<td align="right">
						<table cellpadding="0" cellspacing="0" border="0">
							<tr>
								<td><s:property value="currentPage"/> / </td>
								<td><s:property value="totalPage"/></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>
		        	<!-- -->
		        	<table width="780" border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse;" bordercolor="#878787" class="le">
		            	<tr class="ce">
		                  <td width="50" height="30" class="l_text">번호</td>
		                  <td width="480" class="l_text">제목</td>
		                  <td width="100" class="l_text">작성자</td>
		                  <td width="100" class="l_text">작성일자</td>
		                  <td width="50" class="l_text">조회수</td>
		              </tr>
		              <s:iterator value="boardlist">
			              <tr>
			              		<td class="ce" height="25"><s:property value="no"/></td>
			              		<td style="padding-left: 10px;">
			              		<s:if test="%{lev > 0}">
			              			<c:forEach var="i" begin="1" end="${lev}">&nbsp;&nbsp;&nbsp;</c:forEach><img src='xboard/img/i_reply.gif' />
			              		</s:if>
			                    <a href="./read.action?no=<s:property value="no"/>&cmd=read&page=<s:property value="currentPage"/>"><s:property value="subject"/> <span class="cmt_txt"><s:if test="commentcnt > 0">(<s:property value="commentcnt" />)</s:if></span></a>
			                    </td>
			                    <td class="ce">
			                    	<s:if test="%{email == '' || email == null}">
									<s:property value="writer"/>
									</s:if>
									<s:else>
									<a href="mailto:<s:property value="email"/>"><s:property value="writer"/></a>
									</s:else>	
			                    </td>
			                    <td class="ce"><s:property value="regdate"/></td>
			                    <td class="ce"><s:property value="viewcnt"/></td>
			              </tr>
		              </s:iterator>
		           </table>
		        </td>
		    </tr>
		    <tr>
		    	<td style="padding-top:10px;">
		        	<table border="0" cellpadding="0" cellspacing="0" width="780" class="le">
		            	<tr>
		            	<td width="462">
		                   	<form action="./writefrom.action" name="frm" method="post">
		                   		<input type="hidden" name="cmd" value="new">
		                    	<input class="b_style t_btn" type="button" value="글작성" onclick="fn_write();">
		                   	</form>
		                </td>
		                <td width="313">
		                	<form action="./list.action" name="searchFrm" method="post">
			                   	<select name="searchType" class="select2">
			                   		<option value="subject">글제목</option>
			                   		<option value="writer">작성자</option>
			                   		<option value="content">내용</option>
			                   	</select>
			                	<input type="text" name="searchText" class="i_style input3">
			                	<input align="right" class="b_style t_sbtn" type="button" value="검색" onclick="fn_search();">
		                	</form>
		                </td>
		              </tr>
		            </table>
			        </td>
			    </tr>
			    <tr>
			    	<td align="center" style="padding-top:10px;">
			    		<!-- page -->
					    <table border="0" cellpadding="0" cellspacing="0">
                        	<tr>
                           	  	<td><a href="./list.action?page=1" style="text-decoration:none;">&lt;&lt;</a></td>
                           	  	<s:if test="%{currentBlock > 1}">
                           	  		<td style="padding:0 5px 0 5px;"><a href="./list.action?page=<s:property value="startPage-1"/>&searchType=<s:property value="searchType"/>&searchText=<s:property value="searchText"/>">이전</a></td>
                           	  	</s:if>
                           	  	<s:else>
                           	  		<td style="padding:0 5px 0 5px;">이전</td>
                           	  	</s:else>
                           	  	<c:forEach var="i" begin="${startPage}" end ="${endPage}">
                           	  		<c:choose>
                           	  			<c:when test="${i == currentPage}">
                           	  				<td style="padding:0 5px 0 5px; color:#4d8800; font-weight: bold;">${i}</td>
                           	  			</c:when>
                           	  			<c:otherwise>
                           	  				<td style="padding:0 5px 0 5px;"><a href="./list.action?page=${i}&searchType=${searchType}&searchText=${searchText}">${i}</a></td>
                           	  			</c:otherwise>
                           	  		</c:choose>
                           	  	</c:forEach>
                           	   <s:if test="%{totalPage>endPage}">
                                	<td style="padding:0 5px 0 5px;"><a href="./list.action?page=<s:property value="endPage+1"/>&searchType=<s:property value="searchType"/>&searchText=<s:property value="searchText"/>">다음</a></td>
                               </s:if>
                               <s:else>
                               	<td style="padding:0 5px 0 5px;">다음</td>                  
                               </s:else>
                                <td><a href="./list.action?page=<s:property value="totalPage"/>" style="text-decoration:none;">&gt;&gt;</a></td>
                            </tr>
	                     </table>
			    	</td>
			    </tr>
			</table>
	    </td>
	</tr>
</table>
</body>
</html>


